﻿CREATE PROCEDURE [dbo].[utl_CreateSPForTable]
@Table [sysname], @ParentObject [sysname]=NULL
AS
BEGIN
	IF @ParentObject IS NULL
	BEGIN
	    EXECUTE [dbo].[utl_CreateSPScriptTable]
	    SET @ParentObject = OBJECT_NAME(@@PROCID)
	END
	
	EXECUTE [dbo].[utl_CreateSPDel]    @Table, @ParentObject
	EXECUTE [dbo].[utl_CreateSPIns]    @Table, @ParentObject
	EXECUTE [dbo].[utl_CreateSPSel]    @Table, @ParentObject
	EXECUTE [dbo].[utl_CreateSPSelAll] @Table, @ParentObject
	EXECUTE [dbo].[utl_CreateSPSelBy]  @Table, @ParentObject
	EXECUTE [dbo].[utl_CreateSPUpd]    @Table, @ParentObject
	EXECUTE [dbo].[utl_CreateSPView]   @Table, @ParentObject
	--EXECUTE [dbo].[utl_CreateSPTvf]	 @Table, @ParentObject
		
	IF @ParentObject = OBJECT_NAME(@@PROCID)
	BEGIN
	    SELECT Line
	    FROM   CreateSPScriptTable
	    ORDER BY
	           ID
	END
END

